#1.看代码写结果
# v1 = [1,2,3,4,5]
# v2 = [v1,v1,v1]
# v1.append(6)
# print(v1)
# print(v2)
'''
[1, 2, 3, 4, 5, 6]
[[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6]]
'''

#2.看代码写结果
# v1 = [1,2,3,4,5]
# v2 = [v1,v1,v1]
# v2[1][0] = 111
# v2[2][0] = 222
# print(v1)
# print(v2)
'''
[222, 2, 3, 4, 5]
[[222, 2, 3, 4, 5], [222, 2, 3, 4, 5], [222, 2, 3, 4, 5]]
'''

#3.看代码写结果，并解释每一步的流程。
'''
v1 = [1,2,3,4,5,6,7,8,9]
v2 = {}
for item in v1:
    if item < 6:                #循环v1中的每个元素和6比较
        continue                #小于6跳出当前循环
    if 'k1' in v2:
        v2['k1'].append(item)
    else:
        v2['k1'] = [item]       #把v1中大于6的值放到"k1"的值中
print(v2)
'''

#4.简述赋值和深浅拷贝？
'''
浅拷贝：只拷贝第一层元素
深拷贝：不可变的数据类型共用,可变的数据类型重新开辟一个空间
'''

#5.看代码写结果

# import copy
# v1 = "alex"
# v2 = copy.copy(v1)
# v3 = copy.deepcopy(v1)
# print(v1 is v2)
# print(v1 is v3)
'''
True
True
'''

#6.看代码写结果
# import copy
# v1 = [1,2,3,4,5]
# v2 = copy.copy(v1)
# v3 = copy.deepcopy(v1)
# print(v1 is v2)
# print(v1 is v3)
'''
False
False
'''

#7.看代码写结果

# import copy
# v1 = [1,2,3,4,5]
# v2 = copy.copy(v1)
# v3 = copy.deepcopy(v1)
# print(v1[0] is v2[0])
# print(v1[0] is v3[0])
# print(v2[0] is v3[0])
'''
True
True
True
'''

#8.看代码写结果

# import copy
# v1 = [1,2,3,4,[11,22]]
# v2 = copy.copy(v1)
# v3 = copy.deepcopy(v1)
# print(v1[-1] is v2[-1])
# print(v1[-1] is v3[-1])
# print(v2[-1] is v3[-1])
'''
True
False
False
'''

#9.看代码写结果

# import copy
#
# v1 = [1,2,3,{"name":'太白',"numbers":[7,77,88]},4,5]
# v2 = copy.copy(v1)
#
# print(v1 is v2)             #Fslse
#
# print(v1[0] is v2[0])       #Ture
# print(v1[3] is v2[3])       #Ture
#
# print(v1[3]['name'] is v2[3]['name'])       #Ture
# print(v1[3]['numbers'] is v2[3]['numbers'])     #Ture
# print(v1[3]['numbers'][1] is v2[3]['numbers'][1])   #Ture
'''
False
True
True
True
True
True
'''

#10.看代码写结果

# import copy
# v1 = [1,2,3,{"name":'太白',"numbers":[7,77,88]},4,5]
# v2 = copy.deepcopy(v1)
# print(v1 is v2)                     #False
# print(v1[0] is v2[0])               #Ture
# print(v1[3] is v2[3])               #False
#
# print(v1[3]['name'] is v2[3]['name'])   #Ture
# print(v1[3]['numbers'] is v2[3]['numbers']) #False
# print(v1[3]['numbers'][1] is v2[3]['numbers'][1])   #Ture
'''
False
True
False
True
False
True
'''

# 11.请说出下面a,b,c三个变量的数据类型。
# a = ('太白金星')            #字符串
# b = (1,)                   #元组
# c = ({'name': 'barry'})    #字典
'''
字符串
元组
字典
'''

#12.按照需求为列表排序：
l1 = [1, 3, 6, 7, 9, 8, 5, 4, 2]
# 从大到小排序
'''
# l1.sort(reverse = True)
# print(l1)
'''
# 从小到大排序
'''
l1.sort()
print(l1)
'''
# 反转l1列表
'''
l1.reverse()
print(l1)
'''

#13.利用python代码构建一个这样的列表(升级题)：
#[['_','_','_'],['_','_','_'],['_','_','_']]
'''
lst1 = []
lst2 = []
for i in range(3):
    lst1.append("_")
for i in range(3):
    lst2.append(lst1)
print(lst2)
'''

#14.看代码写结果：
# l1 = [1,2,]
# l1 += [3,4]
# print(l1)           #[1,2,3,4,]
'''
[1,2,3,4,]
'''

#15.看代码写结果：
# dic = dict.fromkeys('abc',[])
# dic['a'].append(666)
# dic['b'].append(111)
# print(dic)          #{a:[666,111],b:[666,111],c:[666,111]}
'''
{a:[666,111],b:[666,111],c:[666,111]}
'''

#16.l1 = [11, 22, 33, 44, 55]，请把索引为奇数对应的元素删除
'''
l1 = [11, 22, 33, 44, 55]
for i in range(len(l1)-2,-1,-2):
    del l1[i]
print(l1)
'''
# l1 = [11, 22, 33, 44, 55]
# del l1[1:4:2]
# print(l1)

#17.dic = {'k1':'太白','k2':'barry','k3': '白白', 'age': 18} 请将字典中所有键带k元素的键值对删除.
'''
dic = {'k1':'太白','k2':'barry','k3': '白白', 'age': 18}
dic1 = dic.copy()
for i in dic1:
    if "k" in i:
        dic.pop(i)
print(dic)
'''

# 18.完成下列需求：
s1 = '宝元'
# 将s1转换成utf-8的bytes类型。
'''
print(s1.encode("utf-8"))
'''
# 将s1转化成gbk的bytes类型。
'''
print(s1.encode("gbk"))
'''
'''
b = b'\xe5\xae\x9d\xe5\x85\x83\xe6\x9c\x80\xe5\xb8\x85'
print(b.decode())
'''

# b为utf-8的bytes类型，请转换成gbk的bytes类型。
'''
b = b'\xe5\xae\x9d\xe5\x85\x83\xe6\x9c\x80\xe5\xb8\x85'
a = b.decode()
print(a.encode("gbk"))
'''

# 19.用户输入一个数字，判断一个数是否是水仙花数。
# 水仙花数是一个三位数, 三位数的每一位的三次方的和还等于这个数.
# 那这个数就是一个水仙花数,
# 例如: 153 = 1**3 + 5**3 + 3**3
# s = 0
# while 1:
#     sum = (input("请输入一个数："))
#     if sum.isdecimal():
#         for i in sum:
#             s += int(i) ** 3
#             if s == int(sum):
#                 print("是水仙花数！")
#             else:
#                 print("不是水仙花数！")
#     else:
#         print("请重新输入：")


'''
m=input("请输入三位数字：")
if m.isdecimal()and 99<int(m)<1000:
     a=m[0]
     b=m[1]
     c=m[2]
     if int(a)**3+int(b)**3+int(c)**3==int(m):
         print("是水仙花数字")
     else:
        print("不是水仙花数字")
else:
    print("输入错误，请重新输入：")
'''

# 20.把列表中所有姓周的⼈的信息删掉(此题有坑, 请慎重):
# lst = ['周⽼⼆', '周星星', '麻花藤', '周扒⽪']
# 结果: lst = ['麻花藤']
'''
lst = ['周⽼⼆', '周星星', '麻花藤', '周扒⽪']
lst1 = lst[:]
for i in lst1:
    if "周" in i:
         lst.remove(i)
print(lst)
'''

# 21.车牌区域划分, 现给出以下车牌. 根据车牌的信息, 分析出各省的车牌持有量. (选做题)
# cars = ['鲁A32444','鲁B12333','京B8989M','⿊C49678','⿊C46555','沪 B25041']
# locals = {'沪':'上海', '⿊':'⿊⻰江', '鲁':'⼭东', '鄂':'湖北', '湘':'湖南'}
# 结果: {'⿊⻰江':2, '⼭东': 2, '上海': 1}
'''
cars = ['鲁A32444','鲁B12333','京B8989M','⿊C49678','⿊C46555','沪 B25041']
locals = {'沪':'上海', '⿊':'⿊⻰江', '鲁':'⼭东', '鄂':'湖北', '湘':'湖南'}
dic = {}
for i in cars:
    k = i[0]
    if k in locals:
        nk = locals[k]
        dic[nk] = dic.get(nk,0)+1
print(dic)
'''

